home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / smaltalk / manchest.lha / MANCHESTER / manchester / 4.1 / Collection-asStringWithCharacter.st < prev    next >
Text File  |  1993-07-24  |  993b  |  34 lines

  1. "    NAME        Collection-asStringWithCharacter
  2.     AUTHOR        Bernard Horan <bernard@is.morgan.com>
  3.     CONTRIBUTOR    Bernard Horan <bernard@is.morgan.com>
  4.     FUNCTION     convert a collection into a string
  5.     ST-VERSIONS    4.1
  6.     PREREQUISITES     
  7.     CONFLICTS     
  8.     DISTRIBUTION    global
  9.     VERSION        1.0
  10.     DATE        September 1992
  11.     SUMMARY        An additional converting method to convert a collection to a string, with a specified character as the delimiter between elements. See comment example. BH, 28/9/92"
  12. !
  13.  
  14. 'From Objectworks\Smalltalk(R), Release 4.1 of 15 April 1992 on 29 September 1992 at 1:24:43 am'!
  15.  
  16.  
  17.  
  18. !Collection methodsFor: 'converting'!
  19.  
  20. asStringWithCharacter: aCharacter 
  21.     "Convert me into a string, with aCharacter as the delimiter between elements.
  22.     Bernard Horan, 29 September 1992. Example:
  23.     Collection allSubclasses asStringWithCharacter: Character cr "
  24.     | stream |
  25.     stream := String new writeStream.
  26.     self
  27.         do: 
  28.             [:i | 
  29.             i printOn: stream.
  30.             stream nextPut: aCharacter].
  31.     stream skip: -1.
  32.     ^stream contents! !
  33.  
  34.